package com.yin.lock8;

// synchronized
public class Demo01 {
    public static void main(String[] args) {
        Phone1 phone = new Phone1();
        new Thread(phone::sms, "A").start();
        new Thread(phone::sms, "B").start();
    }
}

class Phone1 {
    public synchronized void sms() {
        System.out.println(Thread.currentThread().getName() + "sms");
        call();
    }

    public synchronized void call() {
        System.out.println(Thread.currentThread().getName() + "call");
    }
}
